<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

  <title>e网批发管理后台</title>
  <?php include("common/conn.php"); if($_SESSION['userid']==""){echo "<script>window.location.href='login.php';</script>";} 


  ?>
  <script type="text/javascript" src="js/jquery.min.js"></script>
  <link href="css/styles.css" rel="stylesheet" type="text/css" />
  <link href="css/style2.css" rel="stylesheet" type="text/css" />

  <script type="text/JavaScript">
    <!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
//-->
</script>
</head>

<body>

  <!--header-->
  <?php include("common/header.php");?>
  <!--header end-->


<!-- 
    <td scope="col">
      <?php
      switch ($sdg30[type]) {
        case 0:
          echo "图文详情广告";
          break;
        
        case 1:
          echo "商店分类广告";
          break;

        case 2:
          echo "商家广告";
          break;
      }
      ?>
    </td>

 -->



  <!-- staqrt subnav -->
  <div id="sub_nav">

    <div id="subnav_wrap" class="container_12">

      <!-- start sub nav list -->
      <div id="subnav" class=" grid_12">
        <ul>
          <li><a href="wallet.php?t=shop" <?php if($_GET['t']!='user'){ ?> class='sub_nav_active'<?php }?> >店铺钱包</a></li>
          <li><a href="wallet.php?t=user" <?php if($_GET['t']=='user'){ ?> class='sub_nav_active'<?php }?> >用户钱包</a></li>
          <li><a href="walletMoney.php?tx=shop" >提现审核</a></li>
        </ul>
      </div>

    </div>
<br/><br/><br/>
  <div class="container_12" >
    <form action="?t=<?php if($_REQUEST['t']=='user'){echo 'user';}else{echo 'shop';} ?>" method="post">
      <input class="text" type="text" placeholder="搜索关键字"  name="keywords"/>
      <input name="" type="submit" value="搜索" class="submit"/>
    </form>
  </div>

  </div>
  <div class="container_12">
    <!-- <input type="button" class="submit" value="新增热词" onclick="add();"> -->
  </div>
  <!-- end sub_nav -->
  <div class="container_12" style="background: #fff; border:0px; position:relative">

  </div>
    <form action="?del=ok" method="post">
      <div class="container_12">

        <table width="100%" border="0" cellpadding="0" cellspacing="0">
          <tr>
            <th width="5%" scope="col">
              <input type="checkbox" name="checkbox" id="checkbox" class="checkall" /><label for="checkbox"></label></th>
              <th width="13%" scope="col">id</th>
              <th width="13%" scope="col">名称</th>
              <th width="18%" scope="col">金额</th>
              <th width="13%" scope="col">操作</th>
            </tr> 
            
<?php 
mysql_query('SET NAMES UTF8');

$ren="1";
$sex="0";

$perNumber=20; //每页显示的记录数
$page=$_GET['page']; //获得当前的页面值
if($_REQUEST[t]=="user")
{
  if($_REQUEST[keywords]){
    $count=mysql_query("select count(*) from user where niname like '%".$_REQUEST[keywords]."%'");
  }else{
    $count=mysql_query("select count(*) from user where ");
  }
  
}else{
  if($_REQUEST[keywords]){
    $count=mysql_query("select count(*) from shop where name like '%".$_REQUEST[keywords]."%'");
  }else{
    $count=mysql_query("select count(*) from shop ");
  }
  
}

//获得记录总数
$rs=mysql_fetch_array($count); 
$totalNumber=$rs[0];
$totalPage=ceil($totalNumber/$perNumber); //计算出总页数

if (!isset($page)) {
  $page=1;
} //如果没有值,则赋值1
$startCount=($page-1)*$perNumber; //分页开始,根据此方法计算出开始的

if ($_REQUEST['t']=="user") {

  if($_REQUEST[keywords]){
    if($_GET['uid']!=''){
       $rert30=mysql_query("select * from user where userid=".$_GET['uid']." niname like '%".$_REQUEST[keywords]."%' limit $startCount,$perNumber");
    }else{
      $rert30=mysql_query("select * from user where niname like '%".$_REQUEST[keywords]."%' limit $startCount,$perNumber");
    }
  }else{
    if($_GET['uid']!=''){
      $rert30=mysql_query("select * from user where userid=".$_GET['uid']." limit $startCount,$perNumber");
    }else{
      $rert30=mysql_query("select * from user limit $startCount,$perNumber");
    }
  }

}else{

  if($_REQUEST[keywords]){
    if($_GET['sid']!=''){
      $rert30=mysql_query("select * from shop where shopid=".$_GET['sid']." name like '%".$_REQUEST[keywords]."%' ");
    }else{
      $rert30=mysql_query("select * from shop where name like '%".$_REQUEST[keywords]."%' ");
    }
    
  }else{
    if($_GET['sid']!=''){
      $rert30=mysql_query("select * from shop where shopid=".$_GET['sid']." limit $startCount,$perNumber");
    }else{
      $rert30=mysql_query("select * from shop limit $startCount,$perNumber");
    }
    
  }

}					


//var_dump("select * from shop where shopid=".$_GET['sid']." limit $startCount,$perNumber");die;
while($sdg30=mysql_fetch_array($rert30)){

  ?>

  <tr>

    <td scope="col"><input type="checkbox" name="checkbox[]" id="checkbox"  value="<?php if($_GET['t']=='user'){ echo $sdg30[userid];}else{ echo $sdg30[shopid]; };?>"/></td>
    <td scope="col"><?php if($_GET['t']=='user'){ echo $sdg30[userid];}else{ echo $sdg30[shopid]; };?></td>
    <td scope="col"><?php if($_GET['t']=='user'){echo $sdg30[niname];}else{echo $sdg30[name];}?></td>
    <td scope="col"><?php echo $sdg30[money];?></td>
    <td scope="col"><a href="walletDetail.php?<?php if($_GET['t']=='user'){echo 't=users&uid';}else{echo 't=shops&sid';} ?>=<?php if($_GET['t']=='user'){ echo $sdg30[userid];}else{ echo $sdg30[shopid]; };?>" target="_blank">查看详情</a></td>
  </tr> 



  <?php }?>
</table>
<div class="grid_12">

  <!-- <div class="clearfix"><input name="" type="submit" value="删除选中" class="submit"/></div> -->

  <ul id="pagination">



    <?php  

    if ($page > 1) { //上一页 ?>
    <li><a     href="?page=1&keywords=<?php echo $_REQUEST[keywords]; ?>">首页</a></li>
    <li><a     href="?page=<?php echo ($page-1); ?>&keywords=<?php echo $_REQUEST[keywords]; ?>">上一页</a></li>
    <?php }

    ?>

    <li class="active"><?php echo $page;?></li>

    <?php



    if ($_GET[page]!=$totalPage) { //下一页 ?>
    <li><a     href="?page=<?php echo ($page+1); ?>&keywords=<?php echo $_REQUEST[keywords]; ?>">下一页</a></li>
    <?php }

    if ($totalPage>1) { //下一页 ?>
    <li><a     href="?page=<?php echo $totalPage; ?>&keywords=<?php echo $_REQUEST[keywords]; ?>">尾页</a></li>

    <?php }?>


  </ul>

</div>           
</div>
</form>
</body>
<script type="text/javascript">
  function add(){
    window.location.href="addad.php";
  }
  $('.onS').on({
    click: function(){
      $('.onS').removeClass("sub_nav_active");
      $(this).addClass("sub_nav_active");
    },
  });
</script>
</html>
